<?php
session_start();
require_once '../conn/conn.class.php';
$usrName = $_GET['name'];
$uPsw = $_GET['psw'];
$arr='';
$myDb=new conn('127.0.0.1','root','root','phplogin');
if($usrName!='' && $uPsw!=''){
	$sql="select * from tb_register where user='".$usrName."' and password='".$uPsw."'";
	if($myDb->mysqli_get_rows($sql) >= 0){
		if(is_array($arr=$myDb->get_row_array($sql))){
			if($arr[10]=='0'){
				$sql2="update tb_register set active=1 where user='".$usrName."' and password='".$uPsw."'";
				if($myDb->aduRst($sql2) == 1 ){
					$_SESSION['userName']=$usrName;
					$_SESSION['PSW']=$uPsw;
					echo "<script> alert('账号激活成功'); window.location.href='../main.php';</script>";
				}else{
					echo "<script> alert('激活失败！'); window.location.href='../register.php'; </script>";
				}
			}else{
				$_SESSION['userName']=$usrName;
				$_SESSION['PSW']=$uPsw;
				echo "<script> alert('您的账号已激活!'); window.location.href='../main.php'; </script>";
			}
		}
		$myDb->close_rst();
		$myDb->close_mysql();
	}else{
		echo "<script> alert('激活失败！'); window.location.href='../register.php'; </script>";
	}
}else{
	echo "<script> alert('激活失败!'); </script>";
}
